//
//  ActivityViewDemo.m
//  Exercise
//
//  Created by zhouxiaobo on 15/11/12.
//  Copyright © 2015年 mapath. All rights reserved.
//

#import "ActivityViewDemo.h"

@interface ActivityViewDemo ()

@end

@implementation ActivityViewDemo

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor purpleColor];
    
    UIActivityIndicatorView *indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    
    indicatorView.center = CGPointMake(screenWidth/2, screenHeight/2);
    //indicatorView.hidesWhenStopped = NO; //图片静止
    [indicatorView startAnimating]; //开启动画
    [self.view addSubview:indicatorView];
    
    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES]; //上面网络后面的小图标也一起转动
    
    //开启定时器
    [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(stopIndicator:) userInfo:indicatorView repeats:NO];
}

- (void)stopIndicator:(NSTimer *)timer {
    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO]; //停止上面网络后面的小图标转动
    UIActivityIndicatorView *indicatorView  = timer.userInfo;
    [indicatorView stopAnimating];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
